package com.community_cloud.server.servlets;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.user_hosted_storage.server.bl.RegistrationTimerRemote;

/**
 * Application Lifecycle Listener implementation class StartUpListener
 *
 */
public class StartUpListener implements ServletContextListener {

	private RegistrationTimerRemote registrationTimer;

	
	/**
	 * Default constructor. 
	 */
	public StartUpListener() {
		try {
			
			registrationTimer = InitialContext.doLookup(RegistrationTimerRemote.class.getName());
			
			
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see ServletContextListener#contextInitialized(ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent contextEvent) {
		System.out.println("Starting registration task");
		registrationTimer.startTask();
	}

	

	/**
	 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent arg0) {

	}	
}
